<template>
  <div>
    <div class="ui  info attached message" v-if='$store.state.isDetail'>
      <p>{{val}}</p>
    </div>
    <template v-else>
      <myenum v-if="need_contact.fval!==undefined" :field="need_contact" @setVo='setEnum' ></myenum>
      <myenum v-if="need_identity.fval!==undefined" :field="need_identity" @setVo='setEnum' ></myenum>
      <myenum v-if="enumField_aaa.fval!==undefined" type="checkbox" :field="enumField_aaa" @setVo='setEnum' ></myenum>
      <!--<input type="text" v-validate="'required'" data-vv-as="是否需要身份信息" v-model.trim="val.need_i" name="need_i"-->
             <!--placeholder="请输入是否需要身份信息">-->
      <!--<errmsg v-show="errors.has('need_i')">-->
        <!--{{ errors.first('need_i') }}-->
      <!--</errmsg>-->
      <!--<input type="text" v-validate="'required'" data-vv-as="是否需要出行时间" v-model.trim="val.aaa" name="aaa"-->
             <!--placeholder="请输入是否需要出行时间">-->
      <!--<errmsg v-show="errors.has('aaa')">-->
        <!--{{ errors.first('aaa') }}-->
      <!--</errmsg>-->

    </template>
  </div>
</template>

<script type="text/ecmascript-6">
  import tool from 'src/util/tool';
  import util from '_util/index';

  import errmsg from 'components/valid/errmsg';
  import myenum from 'components/field/enum';
  const store = util.store

  export default {
    data() {
      return {
        val: {
          need_contact:0,
          need_identity:0,
          aaa:0,
        },
        need_contact:{
          name:'need_contact',
          title:'旅客信息',
          enum_val:[
            '不需要','需要'
          ]
        },
        need_identity:{
        name:'need_identity',
          title:'份数限制',
          enum_val:[
          '否','是'
        ]
      },
        enumField_aaa:{
          name:'aaa',
          title:'下拉',
          enum_val:[
            {
              id:'0',
              title:'aaa'
            },
            {
              id:'1',
              title:'bbb'
            },
            {
              id:'2',
              title:'cccc'
            },
          ]
        },
      }
    },
    components: {errmsg,myenum},
    methods: {
      setEnum(name, val){
        this.val[name]=val
      }
    },
    watch: {
      val: {
        handler:function (val, old) {

          this.$emit('setVo', this.field.name, val)
        },
        deep:true
      },
      hasError: function (val, old) {
        store.push(this, 'setVoError', 'voErrors', this.field.name, this.errors.first(this.field.name))
      }
    },
    computed: {
      placeholder() {
        return `请输入${this.field.title}`
      },
      hasError(){
        return this.errors.has(this.field.name)
      }
    },
    props: ['field'],
    created() {
//      this.val = this.field.fval
      this.need_contact.fval=0
      this.need_identity.fval=0
      this.enumField_aaa.fval=0
    },
    mounted() {
    }
  };
</script>

<style scoped>
  .field {
  }
</style>
